//
//  FGYMYTableViewCell.m
//  01 - shop
//
//  Created by ma c on 16/8/17.
//  Copyright (c) 2016年 beijing. All rights reserved.
//

#import "FGYMYTableViewCell.h"

@interface FGYMYTableViewCell()

@property (strong, nonatomic) UILabel * titleLabel;
@property (strong, nonatomic) UIImageView * iconImageView;
@property (strong, nonatomic) UILabel * LineLabel;
@property (strong, nonatomic) UIImageView * nextImageView;

@end

@implementation FGYMYTableViewCell

- (void)setDict:(NSDictionary *)dict{
    _dict = dict;
    _titleLabel.text = self.dict[@"title"];
    _iconImageView.image = [UIImage imageNamed:self.dict[@"image"]];
    
    if (dict[@"nextImage"]) {
        _nextImageView.hidden = YES;
    }
    
        _nextImageView.image = [UIImage imageNamed:@"下一步"];

    [_LineLabel setBackgroundColor:Separator_Color];

    
}


- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont systemFontOfSize:18];
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}

- (UIImageView *)iconImageView{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc]init];
    }
    return _iconImageView;
}

- (UILabel *)LineLabel{
    if (!_LineLabel) {
        _LineLabel = [[UILabel alloc]init];
    }
    return _LineLabel;
}

- (UIImageView *)nextImageView{
    if (!_nextImageView) {
        _nextImageView = [[UIImageView alloc]init];
    }
    return _nextImageView;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addSubview:self.titleLabel];
        [self addSubview:self.LineLabel];
        [self addSubview:self.iconImageView];
        [self addSubview:self.nextImageView];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
        __weak typeof(self)weakSelf = self;
    [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerY.equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.mas_left).offset(15);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(140, 15));
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.iconImageView.mas_right).offset(15);
    }];
    
    [_nextImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.right.equalTo(weakSelf.mas_right).offset(-15);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    
    [_LineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.titleLabel.mas_left);
        make.right.equalTo(weakSelf.mas_right);
        make.height.equalTo(@1);
        make.bottom.equalTo(weakSelf.mas_bottom);
    }];
    
    
}

@end
